package com.etennis.utils;

public class WinRoundRate {

    // 从数据库获取参数的伪代码
    // winnerRounds : 作为胜者的胜局分之和
    // sum(when win_A1_id=id or win_A2_id=id then pointA else 0) as winnerRounds
    // loserRounds : 作为败者的胜局分之和
    // sum(when lose_B1_id=id or lose_B2_id then pointB else 0) as winnerRounds



    // winRounds : 胜局
    // sum(when win_A1_id=id or win_A2_id=id then pointA when lose_B1_id=id or lose_B2_id then pointB else 0) as winRounds
    // totalRounds : 所有局数之和
    // sum(when win_A1_id=id or win_A2_id=id or lose_B1_id=id or lose_B2_id then pointA+pointB else 0) as totalRounds
    // winRoundRate : 胜局率
    // winRoundRate=winRounds/totalRounds

    public double winRoundRate(Long winRounds,Long totalRounds){
        if(totalRounds==0){return 0.0;}

        return (double)winRounds/(double)totalRounds;
    }


//    public double winRoundRate(Long winnerRounds,Long loserRounds,Long totalRounds){
//        if(totalRounds==0){return 0.0;}
//        Double winRound=(double)winnerRounds+(double)loserRounds;
//
//        return winRound/(double)totalRounds;
//    }

}
